package com.godpaper.the3directs.busniess.factorys
{
	import com.godpaper.the3directs.model.BoardModel;
	import com.godpaper.the3directs.model.PiecesModel;
	import com.godpaper.the3directs.util.NumberUtil;
	import com.godpaper.the3directs.views.ChessBoard;
	import com.godpaper.the3directs.views.components.*;
	
	import de.polygonal.ds.GraphNode;
	
	import flash.events.EventDispatcher;
	import flash.geom.Point;
	
	import mx.core.Application;
	
	public class ButtonFactory extends EventDispatcher
	{
		public static var chessBoard:ChessBoard;
		public static const FLAG_RED:String = "red";
		public static const FLAG_BLUE:String = "blue";
		private static const MAX_PIECE_NUM:int = 32;
		public static const MAX_GASKET_NUM:int = 64;
		
		public function ButtonFactory()
		{
			//TODO: implement function
		}
		public static const TYPE_PIECE:String = "pieceButton";
		public static const TYPE_GASKET:String = "gasketButton";
		
		public static function produce(type:String,boardTarget:ChessBoard,flagColor:String=null):void
		{
			//restore board;
			chessBoard = boardTarget;
			switch(type)
			{
				case TYPE_PIECE:
					
					if(flagColor==FLAG_RED)
					{
						//Postive RED
						for(var i:int=0;i<MAX_PIECE_NUM;i++)
						{
							var pieceButtonRED:PieceButton = new PieceButton();
//			iPieceButton = PopUpManager.createPopUp(chessBoard,PieceButton);
//			PopUpManager.centerPopUp(iPieceButton);
							pieceButtonRED.styleName = PieceButton.BUTTON_STYLE_NAME_RED;
							pieceButtonRED.name = pieceButtonRED.pieceVO.name = PieceButton.NAME_PREFIX_RED.concat(i.toString());
							pieceButtonRED.label = i.toString();
							pieceButtonRED.enabled = false;
							pieceButtonRED.pieceVO.position = [-2,-2];
							//add to chessBoard
							chessBoard.addChild(pieceButtonRED);
							pieceButtonRED.x = NumberUtil.randomNumberWithScope(440,560);
							pieceButtonRED.y = NumberUtil.randomNumberWithScope(320,440);
							//push to collection;
							PiecesModel.getInstance().redPiecesCollection.addItem(pieceButtonRED);
							
						}
						
					}else
					{
						//Nagetive BLUE
						for(var j:int=0;j<MAX_PIECE_NUM;j++)
						{
							var pieceButtonBLUE:PieceButton = new PieceButton();
//							iPieceButton = PopUpManager.createPopUp(chessBoard,PieceButton);
//							PopUpManager.centerPopUp(iPieceButton);
							pieceButtonBLUE.styleName = PieceButton.BUTTON_STYLE_NAME_BLUE;
							pieceButtonBLUE.name = pieceButtonBLUE.pieceVO.name = PieceButton.NAME_PREFIX_BLUE.concat(j.toString());
							pieceButtonBLUE.label = j.toString();
//							pieceButtonBLUE.enabled = false;
							pieceButtonBLUE.pieceVO.position = [-1,-1];
							//add to chessBoard
							chessBoard.addChild(pieceButtonBLUE);
							pieceButtonBLUE.x = NumberUtil.randomNumberWithScope(0,140);
							pieceButtonBLUE.y = NumberUtil.randomNumberWithScope(320,440);
							
							//push to collection;
							PiecesModel.getInstance().bluePiecesCollection.addItem(pieceButtonBLUE);
						}
						trace("initialized gamePosition@ButtonFactory:",BoardModel.getInstance().gamePosition.dump());
					}
					break;
				case TYPE_GASKET:
					for(var ii:int=0;ii<MAX_GASKET_NUM;ii++)
					{
						var gasketButton:GasketButton = new GasketButton();
						gasketButton.name = GasketButton.NAME_PREFIX.concat(ii.toString());
						gasketButton.label = ii.toString();
						
						if(0<=ii&&ii<=14)
						{
							gasketButton.x = gasketButton.width/2*ii;
							gasketButton.y = 0;
							gasketButton.styleName = (ii%2)!=1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii,0];
						
							BoardModel.getInstance().gasketsPosition.sett(ii,0,gasketButton);
						}else if(ii>14&&ii<=27)
						{
							gasketButton.x = gasketButton.width/2*(ii-14);
							gasketButton.y = gasketButton.height;
							gasketButton.styleName = (ii%2)==1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-14,1];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-14,1,gasketButton);
						}else if(ii>27&&ii<=38)
						{
							gasketButton.x = gasketButton.width/2*(ii-26);
							gasketButton.y = gasketButton.height*2;
							gasketButton.styleName = (ii%2)!=1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-26,2];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-26,2,gasketButton);
						}else if(ii>38&&ii<=47)
						{
							gasketButton.x = gasketButton.width/2*(ii-36);
							gasketButton.y = gasketButton.height*3;
							gasketButton.styleName = (ii%2)==1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-36,3];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-36,3,gasketButton);
						}else if(ii>47&&ii<=54)
						{
							gasketButton.x = gasketButton.width/2*(ii-44);
							gasketButton.y = gasketButton.height*4;
							gasketButton.styleName = (ii%2)!=1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-44,4];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-44,4,gasketButton);
						}else if(ii>54&&ii<=59)
						{
							gasketButton.x = gasketButton.width/2*(ii-50);
							gasketButton.y = gasketButton.height*5;
							gasketButton.styleName = (ii%2)==1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-50,5];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-50,5,gasketButton);
						}else if(ii>59&&ii<=62)		
						{
							gasketButton.x = gasketButton.width/2*(ii-54);
							gasketButton.y = gasketButton.height*6;
							gasketButton.styleName = (ii%2)!=1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-54,6];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-54,6,gasketButton);
						}else if(ii>62)
						{
							gasketButton.x = gasketButton.width/2*(ii-56);
							gasketButton.y = gasketButton.height*7;
							gasketButton.styleName = (ii%2)==1?GasketButton.STYLE_TRIANGLE_R180:GasketButton.STYLE_TRIANGLE;
							gasketButton.position = [ii-56,7];
							
							BoardModel.getInstance().gasketsPosition.sett(ii-56,7,gasketButton);
						}
						//lay to chessboard;
						chessBoard.rawChildren.addChild(gasketButton);
						//add to gameGraph;
						var gasketNode:GraphNode = new GraphNode(gasketButton);
						BoardModel.getInstance().gameGraph.addNode(gasketNode,ii);
						//add to gasketCollection;
						PiecesModel.getInstance().gasketCollection.addItem(gasketButton);
					}	
					//initialize gameGrid;
					for(var w:int=0;w<BoardModel.getInstance().gasketsPosition.width;w++)
					{
						for(var h:int=0;h<BoardModel.getInstance().gasketsPosition.height;h++)
						{
							BoardModel.getInstance().gameGridBlue.setWalkable(w,h,false);
							BoardModel.getInstance().gameGridRed.setWalkable(w,h,false);
						}
					}
					
					trace("initialized gasketsPosition@ButtonFactory:",BoardModel.getInstance().gasketsPosition.dump());
					
					//connect nodes with arc,and set gasketButtons relationship 
					//0 [0,0] 1
						//right
						BoardModel.getInstance().gameGraph.addArc(0,1,1);
						(BoardModel.getInstance().gasketsPosition.gett(0,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(1,0);
						//add to boundary detecte filters;
							//adjacent
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(0,0) as GasketButton );
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(0,0) as GasketButton );
					//1 [1,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(1,0,1);
						(BoardModel.getInstance().gasketsPosition.gett(1,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(0,0);
						//bootom
						BoardModel.getInstance().gameGraph.addArc(1,15,1);
						(BoardModel.getInstance().gasketsPosition.gett(1,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(1,1);
						//right
						BoardModel.getInstance().gameGraph.addArc(1,2,1);
						(BoardModel.getInstance().gasketsPosition.gett(1,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(2,0);	
						
					//2 [2,0] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(2,1,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(1,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(2,3,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(3,0);
						
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(2,0) as GasketButton );
					//3 [3,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(3,2,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(2,0);
						//bottom
						BoardModel.getInstance().gameGraph.addArc(3,17,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(3,1);
						//right
						BoardModel.getInstance().gameGraph.addArc(3,4,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(4,0);
						
					//4 [4,0] 2
						//left 
						BoardModel.getInstance().gameGraph.addArc(4,3,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(3,0);
						//right		
						BoardModel.getInstance().gameGraph.addArc(4,5,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(5,0);	
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(4,0) as GasketButton );
					//5 [5,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(5,4,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(4,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(5,6,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,0);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(5,19,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(5,1);
					//6 [6,0] 2
						//left 
						BoardModel.getInstance().gameGraph.addArc(6,5,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(6,7,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,0);
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(6,0) as GasketButton );
					//7 [7,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(7,6,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(7,8,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,0);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(7,21,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(7,1);
					//8 [8,0] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(8,7,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,0);
						//right	
						BoardModel.getInstance().gameGraph.addArc(8,9,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,0);
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(8,0) as GasketButton );
					//9 [9,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(9,8,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(9,10,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(10,0);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(9,23,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(9,1);
						
					//10 [10,0] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(10,9,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(9,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(10,11,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(11,0);
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(10,0) as GasketButton );
					//11 [11,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(11,10,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(10,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(11,12,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(12,0);
						//bottom		
						BoardModel.getInstance().gameGraph.addArc(11,25,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(11,1);
					//12 [12,0] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(12,11,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(11,0);
						//right	
						BoardModel.getInstance().gameGraph.addArc(12,13,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(13,0);
						//add to boundary detecte filters;
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(12,0) as GasketButton );
					//13 [13,0] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(13,12,1);
						(BoardModel.getInstance().gasketsPosition.gett(13,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(12,0);
						//right
						BoardModel.getInstance().gameGraph.addArc(13,14,1);
						(BoardModel.getInstance().gasketsPosition.gett(13,0) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(14,0);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(13,27,1);
						(BoardModel.getInstance().gasketsPosition.gett(13,0) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(13,1);
					//14 [14,0] 1
						//left
						BoardModel.getInstance().gameGraph.addArc(14,13,1);
						(BoardModel.getInstance().gasketsPosition.gett(14,0) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(13,0);	
						//add to boundary detecte filters;
							//ajacent
						PiecesModel.getInstance().adjacentCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(14,0) as GasketButton );
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(14,0) as GasketButton );
					//15 [1,1] 1
						//top
						BoardModel.getInstance().gameGraph.addArc(15,1,1);
						(BoardModel.getInstance().gasketsPosition.gett(1,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(1,0);	
						//right
						BoardModel.getInstance().gameGraph.addArc(15,16,1);
						(BoardModel.getInstance().gasketsPosition.gett(1,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(2,1);	
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(1,1) as GasketButton );
					//16 [2,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(16,15,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(1,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(16,17,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(3,1);	
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(16,28,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(2,2);	
					//17 [3,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(17,16,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(2,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(17,18,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(4,1);	
						//top	
						BoardModel.getInstance().gameGraph.addArc(17,3,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(3,0);	
					//18 [4,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(18,17,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(3,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(18,19,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(5,1);	
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(18,30,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(4,2);	
					//19 [5,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(19,18,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(4,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(19,20,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,1);	
						//top	
						BoardModel.getInstance().gameGraph.addArc(19,5,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(5,0);	
					//20 [6,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(20,19,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(20,21,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,1);	
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(20,32,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(6,2);	
					//21 [7,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(21,20,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(21,22,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,1);	
						//top	
						BoardModel.getInstance().gameGraph.addArc(21,7,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(7,0);	
					//22 [8,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(22,21,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(22,23,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,1);	
						//bottom
						BoardModel.getInstance().gameGraph.addArc(22,34,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(8,2);	
					//23 [9,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(23,22,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(23,24,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(10,1);	
						//top	
						BoardModel.getInstance().gameGraph.addArc(23,9,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(9,0);	
					//24 [10,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(24,23,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(9,1);	
						//right
						BoardModel.getInstance().gameGraph.addArc(24,25,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(11,1);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(24,36,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(10,2);
					//25 [11,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(25,24,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(10,1);
						//right
						BoardModel.getInstance().gameGraph.addArc(25,26,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(12,1);
						//top	
						BoardModel.getInstance().gameGraph.addArc(25,11,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(11,0);
					//26 [12,1] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(26,25,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(11,1);
						//right
						BoardModel.getInstance().gameGraph.addArc(26,27,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,1) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(13,1);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(26,38,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,1) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(12,2);
					//27 [13,1] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(27,26,1);
						(BoardModel.getInstance().gasketsPosition.gett(13,1) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(12,1);
						//top		
						BoardModel.getInstance().gameGraph.addArc(27,13,1);
						(BoardModel.getInstance().gasketsPosition.gett(13,1) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(13,0);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(13,1) as GasketButton );
					//28 [2,2] 2
						//right
						BoardModel.getInstance().gameGraph.addArc(28,29,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(3,2);
						//top
						BoardModel.getInstance().gameGraph.addArc(28,16,1);
						(BoardModel.getInstance().gasketsPosition.gett(2,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(2,1);
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(2,2) as GasketButton );
					//29 [3,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(29,28,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(2,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(29,30,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(4,2);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(29,39,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,2) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(3,3);
					//30 [4,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(30,29,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(3,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(30,31,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(5,2);
						//top	
						BoardModel.getInstance().gameGraph.addArc(30,18,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(4,1);
					//31 [5,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(31,30,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(4,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(31,32,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,2);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(31,41,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,2) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(5,3);
					//32 [6,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(32,31,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(32,33,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,2);
						//top	
						BoardModel.getInstance().gameGraph.addArc(32,20,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(6,1);
					//33 [7,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(33,32,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(33,34,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,2);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(33,43,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,2) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(7,3);
					//34 [8,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(34,33,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(34,35,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,2);
						//top	
						BoardModel.getInstance().gameGraph.addArc(34,22,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(8,1);
					//35 [9,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(35,34,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(35,36,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(10,2);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(35,45,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,2) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(9,3);
					//36 [10,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(36,35,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(9,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(36,37,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(11,2);
						//top	
						BoardModel.getInstance().gameGraph.addArc(36,24,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(10,1);
					//37 [11,2] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(37,36,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(10,2);
						//right
						BoardModel.getInstance().gameGraph.addArc(37,38,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,2) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(12,2);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(37,47,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,2) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(11,3);
					//38 [12,2] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(38,37,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,2) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(11,2);
						//top	
						BoardModel.getInstance().gameGraph.addArc(38,26,1);
						(BoardModel.getInstance().gasketsPosition.gett(12,2) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(12,1);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(12,2) as GasketButton );
					//39 [3,3] 2
						//right
						BoardModel.getInstance().gameGraph.addArc(39,40,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(4,3);
						//top
						BoardModel.getInstance().gameGraph.addArc(39,29,1);
						(BoardModel.getInstance().gasketsPosition.gett(3,3) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(3,2);
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(3,3) as GasketButton );
					//40 [4,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(40,39,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(3,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(40,41,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(5,3);
						//bottom
						BoardModel.getInstance().gameGraph.addArc(40,48,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,3) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(4,4);
					//41 [5,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(41,40,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(4,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(41,42,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,3);
						//top	
						BoardModel.getInstance().gameGraph.addArc(41,31,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,3) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(5,2);
					//42 [6,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(42,41,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(42,43,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,3);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(42,50,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,3) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(6,4);
					//43 [7,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(43,42,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(43,44,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,3);
						//top	
						BoardModel.getInstance().gameGraph.addArc(43,33,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,3) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(7,2);
					//44 [8,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(44,43,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(44,45,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,3);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(44,53,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,3) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(8,4);
					//45 [9,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(45,44,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(45,46,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(10,3);
						//top	
						BoardModel.getInstance().gameGraph.addArc(45,35,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,3) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(9,2);
					//46 [10,3] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(46,45,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(9,3);
						//right
						BoardModel.getInstance().gameGraph.addArc(46,47,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,3) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(11,3);
						//bottom
						BoardModel.getInstance().gameGraph.addArc(46,54,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,3) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(10,4);
					//47 [11,3] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(47,46,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,3) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(10,3);
						//top	
						BoardModel.getInstance().gameGraph.addArc(47,37,1);
						(BoardModel.getInstance().gasketsPosition.gett(11,3) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(11,2);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(11,3) as GasketButton );
					//48 [4,4] 2
						//right
						BoardModel.getInstance().gameGraph.addArc(48,49,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(5,4);
						//top	
						BoardModel.getInstance().gameGraph.addArc(48,40,1);
						(BoardModel.getInstance().gasketsPosition.gett(4,4) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(4,3);
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(4,4) as GasketButton );
					//49 [5,4] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(49,48,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(4,4);
						//right
						BoardModel.getInstance().gameGraph.addArc(49,50,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,4);
						//bottom
						BoardModel.getInstance().gameGraph.addArc(49,55,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,4) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(5,5);
					//50 [6,4] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(50,49,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,4);
						//right
						BoardModel.getInstance().gameGraph.addArc(50,51,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,4);
						//top	
						BoardModel.getInstance().gameGraph.addArc(50,42,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,4) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(6,3);
					//51 [7,4] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(51,50,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,4);
						//right
						BoardModel.getInstance().gameGraph.addArc(51,52,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,4);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(51,57,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,4) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(7,5);
					//52 [8,4] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(52,51,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,4);
						//right
						BoardModel.getInstance().gameGraph.addArc(52,53,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,4);
						//top	
						BoardModel.getInstance().gameGraph.addArc(52,44,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,4) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(8,3);
					//53 [9,4] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(53,52,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,4);
						//right
						BoardModel.getInstance().gameGraph.addArc(53,54,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,4) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(10,4);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(53,59,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,4) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(9,5);
					//54 [10,4] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(54,53,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,4) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(9,4);
						//top	
						BoardModel.getInstance().gameGraph.addArc(54,46,1);
						(BoardModel.getInstance().gasketsPosition.gett(10,4) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(10,3);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(10,4) as GasketButton );
					//55 [5,5] 2
						//right
						BoardModel.getInstance().gameGraph.addArc(55,56,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,5) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(6,5);
						//top	
						BoardModel.getInstance().gameGraph.addArc(55,49,1);
						(BoardModel.getInstance().gasketsPosition.gett(5,5) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(5,4);
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(5,5) as GasketButton );
					//56 [6,5] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(56,55,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,5) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(5,5);
						//right
						BoardModel.getInstance().gameGraph.addArc(56,57,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,5) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,5);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(56,60,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,5) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(6,6);
					//57 [7,5] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(57,56,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,5) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,5);
						//right
						BoardModel.getInstance().gameGraph.addArc(57,58,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,5) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,5);
						//top	
						BoardModel.getInstance().gameGraph.addArc(57,51,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,5) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(7,4);
					//58 [8,5] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(58,57,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,5) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,5);
						//right
						BoardModel.getInstance().gameGraph.addArc(58,59,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,5) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(9,5);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(58,62,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,5) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(8,6);
					//59 [9,5] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(59,58,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,5) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(8,5);
						//top		
						BoardModel.getInstance().gameGraph.addArc(59,53,1);
						(BoardModel.getInstance().gasketsPosition.gett(9,5) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(9,4);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(9,5) as GasketButton );
					//60 [6,6] 2
						//right
						BoardModel.getInstance().gameGraph.addArc(60,61,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,6) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(7,6);
						//top	
						BoardModel.getInstance().gameGraph.addArc(60,56,1);
						(BoardModel.getInstance().gasketsPosition.gett(6,6) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(6,5);
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(6,6) as GasketButton );
					//61 [7,6] 3
						//left
						BoardModel.getInstance().gameGraph.addArc(61,60,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,6) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(6,6);
						//right
						BoardModel.getInstance().gameGraph.addArc(61,62,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,6) as GasketButton).right = 
						BoardModel.getInstance().gasketsPosition.gett(8,6);
						//bottom	
						BoardModel.getInstance().gameGraph.addArc(61,63,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,6) as GasketButton).bottom = 
						BoardModel.getInstance().gasketsPosition.gett(7,7);
					//62 [8,6] 2
						//left
						BoardModel.getInstance().gameGraph.addArc(62,61,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,6) as GasketButton).left = 
						BoardModel.getInstance().gasketsPosition.gett(7,6);
						//top	
						BoardModel.getInstance().gameGraph.addArc(62,58,1);
						(BoardModel.getInstance().gasketsPosition.gett(8,6) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(8,5);
						//add to boundary detecte filters;
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(8,6) as GasketButton );
					//63 [7,7] 1
						//top
						BoardModel.getInstance().gameGraph.addArc(63,61,1);
						(BoardModel.getInstance().gasketsPosition.gett(7,7) as GasketButton).top = 
						BoardModel.getInstance().gasketsPosition.gett(7,6);	
						//add to boundary detecte filters;
							//opposite
						PiecesModel.getInstance().oppositeCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(7,7) as GasketButton );
							//hypotenuse
						PiecesModel.getInstance().hypotenuseCollection.addItem( BoardModel.getInstance().gasketsPosition.gett(7,7) as GasketButton );
					trace("####################BoardGraph graphNode test#####################");
//					trace("initilized@ButtonFactory:",DebugUtil.dumpGameGraph());
					trace("initilized adjacentCollection@ButtonFactory:",PiecesModel.getInstance().adjacentCollection);
					trace("initilized oppositeCollection@ButtonFactory:",PiecesModel.getInstance().oppositeCollection);
					trace("initilized hypotonuseCollection@ButtonFactory:",PiecesModel.getInstance().hypotenuseCollection);
					break;
				default:
					break;		
			}
			
			
		}
		
		protected static function get chessBoardPoint():Point
		{
			return Application.application.localToGlobal(new Point(chessBoard.x,chessBoard.y));
		}
	}
}